﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TouchExplorer.Controls;
using TouchControls;

namespace TouchExplorer
{    
    /// <summary>
    /// Interaction logic for FilesList.xaml
    /// </summary>
    public partial class FilesList : AdornmentGrid
    {
        private ExplorerViewModel Model
        {
            get
            {
                return DataContext as ExplorerViewModel;
            }
        }

        public FilesList()
        {
            InitializeComponent();
            //if (!App.IsInDesignModeStatic)
            //{
            //    var selector = new FileListItemTemplateSelector(ListFiles);
            //    selector.ListTemplate = (DataTemplate)this.FindResource("FileListItemTemplateByList");
            //    selector.ListPanelTemplate = (ItemsPanelTemplate)this.FindResource("FileListItemPanelByList");
            //    selector.TilesTemplate = (DataTemplate)this.FindResource("FileListItemTemplateByTiles");
            //    selector.TilesPanelTemplate = (ItemsPanelTemplate)this.FindResource("FileListItemPanelByTiles");
            //    ListFiles.ItemTemplateSelector = selector;
            //}
            //Loaded += new RoutedEventHandler(FilesList_Loaded);
        }
        
        void FilesList_Loaded(object sender, RoutedEventArgs e)
        {
            Model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Model_PropertyChanged);
        }
        
        void Model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Display")
            {
                ListFiles.SetBinding(ListBox.ItemsSourceProperty, new Binding(""));
                Binding bd = new Binding("Files");

                ListFiles.SetBinding(ListBox.ItemsSourceProperty, bd);
            }
        }
    }
}
